//class Singleton

export class Singleton /* flash.events.EventDispatcher */ {
  constructor() {
    var loc1 = this["constructor"] as Class;
    if (Singleton.dict[loc1]) {
      throw new Object(
        /* flash.errors.IllegalOperationError */ flash.utils.getQualifiedClassName(
          this
        ) + " 只允许实例化一次！"
      );
    }
    Singleton.dict[loc1] = this;
    return;
  }

  public destory(): void {
    var loc1 = this["constructor"] as Class;
    delete Singleton.dict[loc1];
    return;
  }

  public static getInstance(arg1: Class) {
    return Singleton.dict[arg1];
  }

  public static getInstanceOrCreate(arg1: Class) {
    var loc1 = Singleton.dict[arg1];
    if (loc1) {
      loc1 = new arg1();
      Singleton.dict[arg1] = loc1;
    }
    return loc1;
  }

  public static create(arg1: Class) {
    var loc1 = new arg1();
    Singleton.dict[arg1] = loc1;
    return loc1;
  }

  private static /* var */ dict: Record<any, any> = {};
}
